package com.demo.controller;

import com.demo.common.aop.LoginAop;
import com.demo.common.base.BaseModel;
import com.demo.common.base.ResultModel;
import com.demo.model.User;
import com.demo.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Description: UserController
 * @Author: ChenXueLi
 * @Date: 2018-10-02 11:01
 */
@Api(value = "UserController", description = "用户接口")
@Controller
@CrossOrigin
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @ApiOperation(value = "删除用户", notes = "删除用户接口", httpMethod = "POST")
    @RequestMapping(value = "/deleteUser", method = RequestMethod.POST)
    @ResponseBody
    public ResultModel deleteUser(User user, ResultModel resultModel, HttpServletRequest request, HttpServletResponse response) throws Exception{
        return userService.deleteUser(user, resultModel, request, response);
    }

    @LoginAop
    @ApiOperation(value = "查询用户列表", notes = "查询用户列表接口", httpMethod = "GET")
    @RequestMapping(value = "/getUserList")
    @ResponseBody
    public ResultModel getUserList(ResultModel resultModel, HttpServletRequest request, HttpServletResponse response) throws Exception{
        return userService.getUserList(resultModel, request, response);
    }


    @ApiOperation(value = "快速修改用户状态", notes = "快速修改用户状态接口", httpMethod = "POST")
    @RequestMapping(value = "/modifyState", method = RequestMethod.POST)
    @ResponseBody
    public ResultModel modifyState(User user, ResultModel resultModel, HttpServletRequest request, HttpServletResponse response) throws Exception{
        return userService.modifyState(user, resultModel, request, response);
    }

}
